//
//  ImageEngine.h
//  TestARC
//
//  Created by Rayco on 12-10-17.
//  Copyright (c) 2012年 Test. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "MKNetworkKit.h"

@protocol AppsImageEngineDelegate <NSObject>

@optional

- (void)AppsImageEngineLoadImageComplete:(NSImage*)_image;

- (void)AppsImageEngineLoadAndroidIconsComplete;

@end

typedef void (^ImageEngineBlock)(NSImage *fetchImage,NSURL *url,BOOL isInCache);
typedef void (^ImageEngineErrorBlock)(NSError *error,NSURL *url);
@interface AppsImageEngine : MKNetworkEngine {
    bool icon57x57Done,icon114x114Done,icon512x512Done;
    int androidIconDone;
}

@property (nonatomic,retain) id <AppsImageEngineDelegate> delegate;

+ (id)sharedEngine;

- (void)loadImage:(NSString *)imageUrl onCompletion:(ImageEngineBlock)onCompletion;

- (void)loadImage:(NSString *)imageUrl dimension:(CGSize)size onCompletion:(ImageEngineBlock)onCompletion;

//- (NSImage*) imageFromCGImageRef:(CGImageRef)image;
//
//- (BOOL)saveImage:(NSImage*)image                      //source image
//         saveType:(NSBitmapImageFileType)storageType   //save type "NSJPEGFileType",NSPNGFileType
//       properties:(NSDictionary *)properties         //properties "NSImageCompressionFactor = (NSNumber)0.8"
//         ToTarget:(NSString *) targePath;
//
//- (void)makeAppIconWithImage:(NSImage*)image pathAndSize:(NSDictionary*)dict;

- (void)makeAppIconWithImageUrl:(NSString*)url saveAtPath:(NSString*)path;//For iOS
- (void)loadAndroidIconWithImageUrl:(NSString*)url projectPath:(NSString*)pPath ;// For Android
- (void)loadAndroidIconsUsingGCDWithImageUrl:(NSString*)url projectPath:(NSString*)pPath;// For Android - V2 20130621

- (bool)isMakeingIconDone;//ios图片是否load完
- (bool)isAndroidIconLoadingDone;//android图片是否load完

- (BOOL)saveImage:(NSImage*)image                      //source image
         saveType:(NSBitmapImageFileType)storageType   //save type "NSJPEGFileType",NSPNGFileType
       properties:(NSDictionary *)properties         //properties "NSImageCompressionFactor = (NSNumber)0.8"
         ToTarget:(NSString *) targePath;

@end
